<!--
 * @Author: hucc
 * @Date: 2021-10-08 16:15:54
 * @LastEditors: hucc
 * @LastEditTime: 2021-10-08 20:03:11
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue模板语法</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.13/vue.js"></script>
</head>

<body>
    <div id="app">
        {{msg}} <br> {{msg + boolean}} <br> {{boolean?msg:'null'}}
        <div title="title">div1</div>
        <div v-bind:title="title">
            div2
        </div>
        <!-- data-xxx 自定义属性 -->
        <div :title="title" :data-msg="msg">
            div3
        </div>
        <button v-on:click="clickHandler">修改数据1</button>
        <button @click="clickHandler">修改数据2</button>
        <button @click="msg='hello v-on' ">修改数据3</button>
        <div v-html='htmlCode'></div>
    </div>
    <script>
        let vm = new Vue({
            //当前vue实例的配置项
            el: '#app',
            data: {
                msg: 'hello vue',
                boolean: false,
                title: 'hello v-bind',
                // 模板字符串 ``和${}一起用
                htmlCode: `
                <div>
            <h1>h1</h1>
            <h2>h2</h2>
            <h3>h3</h3>
            <h4>h4</h4>
            <h5>h5</h5>
        </div>
                `
            },
            methods: {
                findAllCategories() {
                    console.log('查询所有栏目信息')
                },

                clickHandler() {
                    //this指代vue实例vm
                    this.msg = "hello v-on"
                }
            },
            created() {
                this.findAllCategories();
            }
        })
    </script>
</body>

</html>